﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Medianamik.Core.Sugar;
using Medianamik.Core;

namespace Medianamik.UI.ConfigManagement
{
    public partial class ControlManagement : BasePage
    {

        #region Fields

        

        #endregion

        #region Events

        protected void Page_Load(object sender, EventArgs e)
        {
            if (CurrentlyEditedContol == null)
            {
                if (!String.IsNullOrEmpty(Request["id"])) //Argument exception 
                    Response.Redirect(ReturnURL, true);

                //Nouveau contrôle
            }
            else //Édition d'un contrôle
            {
                txtControlName.Text = CurrentlyEditedContol.Name;
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region Properties

        public MedianamikControl CurrentlyEditedContol
        {
            get
            {
                if (_currentlyEditedContol == null)
                {
                    Guid controlId;
                    if (StringHelper.IsGuid(Request["id"], out controlId))
                    {
                        _currentlyEditedContol = ConfigManager.GetMedianamikControl(controlId);
                    }
                }

                return _currentlyEditedContol;
            }
        }
        private MedianamikControl _currentlyEditedContol;

        protected string ReturnURL
        {
            get
            {
                return "/medianamik/configmanagement/controlList.aspx";
            }
        }

        #endregion

        #region Methods



        #endregion

    }
}
